<?php

class User_model extends CI_Model {
    
    public function validate()
    {
        $this->db->select('user_name, user_pass, user_type_id');
        $this->db->where('user_name', $this->input->post('username'));
        $this->db->where('user_pass', md5($this->input->post('password')));
        $query = $this->db->get('cs_user');
        
        if($query->num_rows() == 1)
        {
            return $query;
        }
        else
        {
            return false;    
        }
    }
    
    public function get_user_list()
    {
        $query = $this->db->query('SELECT * FROM cs_user;');
        
        if($query->num_rows() > 0)
        {
            return $query->result();
        }
        else
        {
            return false;
        }
    }
    
    public function get_vendor_list()
    {
        $this->load->database();
        
        $query = $this->db->query('SELECT * FROM cs_vendor;');
        
        if($query->num_rows() > 0)
        {
            return $query->result();
        }
        else
        {
            return false;
        }
    }
}